gl path "~/"

use id year g_ gx* homeowner_g value_decile using "$path/Replication/ohio_analysis_local.dta", clear

// drop if missing
drop if gx_safety == .

foreach topic in safety school liquor roads parks aggregation zoning charter senior_children cemetery ///
	current_expenses misc {
	gen gx_`topic'_homeowner = homeowner_g*gx_`topic'
}
compress

reghdfe g_ gx* homeowner_g, a(id value_decile#year) cluster(id)

matrix B = J(11,4,.)
local count = 1
foreach topic in safety school liquor roads parks aggregation zoning charter senior_children cemetery ///
	current_expenses {
	matrix B[`count', 1] = _b[gx_`topic'_homeowner]
	matrix B[`count', 2] = _se[gx_`topic'_homeowner]
	matrix B[`count', 3] = `count'
	count if gx_`topic'==1
	matrix B[`count',4] = r(N)
	local count = `count' + 1
}

svmat B
keep B1 B2 B2 B3 B4
keep if B1 != .
gen name = ""
replace name = "public safety" if _n==1
replace name = "schools" if _n==2
replace name = "liquor" if _n==3
replace name = "roads" if _n==4
replace name = "parks" if _n==5
replace name = "aggregation" if _n==6
replace name = "zoning" if _n==7
replace name = "charter" if _n==8
replace name = "seniors and children" if _n==9
replace name = "cemetery" if _n==10
replace name = "current expenses" if _n==11

gen lb=B1-1.96*B2
gen ub=B1+1.96*B2

sort B1
gen y=_n

scatter y B1, xtitle("Additional Effect of Homeownership on Turnout") ///
	ytitle("") ylabel("") ///
	scale(1.3) || rcap lb ub y, legend(off) horizontal ///
	text(1 -.04 "parks") text(2 -.035 "charter") ///
	text(3 -.03 "current expenses") text(4 -.022 "liquor") ///
	text(5 -.02 "roads") text(6 -.02 "cemetary")  ///
	text(7 -.01 "schools") text(8 0 "public safety") ///
	text(9 0.01 "aggregation") text(10 .01 "seniors and children") ///
	text(11 .02 "zoning")
	
graph export "$path/Replication/figure4.pdf", replace
graph export "$path/Replication/figure4.eps", replace


